import request from '@/config/axios'
import type {Dayjs} from 'dayjs';

/** 数据匹配下载信息 */
export interface DataMatchTask {
    id: number; // ID
    taskName: string; // 任务名称
    taskParams: string; // 任务参数
    taskStatus: string; // 任务状态
    retrievalDays: number; // 检索时间
    downloadUrl: string; // 下载URL
    matchType: string; // 匹配对象
}

// 数据匹配下载 API
export const DataMatchTaskApi = {
    // 查询数据匹配下载分页
    getDataMatchTaskPage: async (params: any) => {
        return await request.get({url: `/vos/data-match-task/page`, params})
    },

    // 查询数据匹配下载详情
    getDataMatchTask: async (id: number) => {
        return await request.get({url: `/vos/data-match-task/get?id=` + id})
    },

    // 新增数据匹配下载
    createDataMatchTask: async (data: DataMatchTask) => {
        return await request.upload({
            url: `/vos/data-match-task/create`,
            data, // 直接传递 FormData
            headers: { 'Content-Type': 'multipart/form-data' } // 明确传递 Content-Type（通常可省略）
        })
    },


    // 修改数据匹配下载
    updateDataMatchTask: async (data: DataMatchTask) => {
        return await request.put({url: `/vos/data-match-task/update`, data})
    },

    // 删除数据匹配下载
    deleteDataMatchTask: async (id: number) => {
        return await request.delete({url: `/vos/data-match-task/delete?id=` + id})
    },

    /** 批量删除数据匹配下载 */
    deleteDataMatchTaskList: async (ids: number[]) => {
        return await request.delete({url: `/vos/data-match-task/delete-list?ids=${ids.join(',')}`})
    },

    // 导出数据匹配下载 Excel
    exportDataMatchTask: async (params) => {
        return await request.download({url: `/vos/data-match-task/export-excel`, params})
    },

    importDownloadTemplate: async () => {
        return request.download({url: '/vos/data-match-task/get-import-template'})
    },
}
